package com.kwin;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;

import java.util.HashSet;

/**
 * jedis 连接 redis 集群
 */
public class TestCluster {
    public static void main(String[] args) {
        HashSet<HostAndPort> nodes = new HashSet<HostAndPort>();
        nodes.add(new HostAndPort("106.53.96.171",6379));
        nodes.add(new HostAndPort("106.53.96.171",6380));
        nodes.add(new HostAndPort("106.53.96.171",6381));
        nodes.add(new HostAndPort("106.53.96.171",6389));
        nodes.add(new HostAndPort("106.53.96.171",6390));
        nodes.add(new HostAndPort("106.53.96.171",6391));
        JedisCluster cluster = new JedisCluster(nodes);

        System.out.println(cluster.set("name", "kwin"));
        System.out.println(cluster.get("name"));

        cluster.close();
    }
}
